home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
program
/
swagg_m.zip
/
MISC.SWG
/
0046_Trapping Runtime Errors.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-11-02
|
982b
|
45 lines
{
JON JASIUNAS
I never use them. if a Program bombs because a disk is full, I just
> catch the run-time error in an Exit proc and report so (I/O-checking
> must be set on, of course).
>I am curious, How do you go about Catching the Run-Time Error. Doesn't it
>just say Runtime Error 103 ?????:?????
You can catch the run-time errors by linking into the Exit chain.
Here's a small example:
}
Unit ErrTrap;
Interface
Implementation
Var
OldExit : Pointer;
Procedure NewExit; Far; { MUST be far! }
begin
if ErrorAddr <> nil then
begin
{-Display custom run-time error message }
WriteLn('Fatal error #', ExitCode);
WriteLn('Address = ', Seg(ErrorAddr^), ':', Ofs(ErrorAddr^));
{-Cancel run-time error so you don't get the default message, too }
ErrorAddr := nil;
{-Zero the errorlevel }
ExitCode := 0;
end;
ExitProc := OldExit;
end;
begin
OldExit := ExitProc;
ExitProc := @NewExit;
end.